//package udpclient;

import java.net.*;
import java.io.*;


public class UDPClient{

	public static void main (String args[]){
	// args give message contents and server hostnames

	String[] line = new String[2];
	BufferedReader inReader = new BufferedReader(new InputStreamReader(System.in));

	try{
		line[0] = inReader.readLine();
		DatagramSocket aSocket = new DatagramSocket();

		while(true)
		{


			line[1]=inReader.readLine();

			//byte[] m = args[0].getBytes();
			byte[] m = line[1].getBytes();
			InetAddress aHost = InetAddress.getByName(line[0]);
			int serverPort = 6789;
			DatagramPacket request =
				new DatagramPacket(m, line[1].length(), aHost, serverPort);
			aSocket.send(request);
			byte[] buffer = new byte[100];
			DatagramPacket reply =
				new DatagramPacket(buffer, buffer.length);
			aSocket.receive(reply);
			System.out.println("Reply: "+ new String(reply.getData()));



		}
		//aSocket.close();
	}catch (SocketException e){System.out.println("Socket:"+ e.getMessage());}
		catch (IOException e) {System.out.println("IO:"+ e.getMessage());}

}
}
